package responeChain.game;

public class Client {
    Player chain = null;

    public  Client(){
        Player chain  = new JiaMu();
        Player jiaZhen = new JiaZhen();
        Player jiabaoyu = new Jiabaoyu();
        Player lindaiyu = new Lindaiyu();

        chain.setNext(jiaZhen);
        jiaZhen.setNext(jiabaoyu);
        jiabaoyu.setNext(lindaiyu);
        lindaiyu.setNext(chain);
        this.chain = chain;
    }

    public void startSendFlow(){
        if (chain == null) {
            return;
        }
        new Thread(() -> {
            try {
                chain.sendFlow();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
    }

    public void stopSendFlow(){
        chain.stop = true;

    }

    public static void main(String[] args)  {
        Client c = new Client();
        c.startSendFlow();
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        c.stopSendFlow();
    }
}
